home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0039
/
source
/
dcprnt24.mod
< prev
next >
Wrap
Text File
|
1997-04-16
|
9KB
|
318 lines
IMPLEMENTATION MODULE DCPrnt24;
(* This program will PRINT pictures. *)
(*--------------------------------------------------------------------*)
(* Version 2.00 August 1988 L.G. Miller. *)
(* Version 1.00 April 1987 L.G.M. *)
(*--------------------------------------------------------------------*)
(* Pressing any mouse button whilst printing will request an
ABORT of the print.
*)
(* IMPORT Trace; *)
FROM SYSTEM IMPORT ADDRESS, ADR;
FROM Bios IMPORT bcostat, bconout;
FROM DCPrtCnv IMPORT PrtCnv24BitSlice;
IMPORT Forms;
FROM VDI IMPORT vq_mouse;
FROM ManyWindows IMPORT VDIHandle, ShowAlert;
FROM Strings IMPORT String, Concat;
FROM DCGlobal IMPORT
(* CONST *)
HiResMaxX, (* = 639; *)
HiResMaxY, (* = 399; *)
HiResNoPlanes, (* = 1; *)
(* TYPE *)
PrinterTypes,
HiResScreen,
PictureImage,
PrintImage;
(* ---------------------------------------------------------- *)
CONST
ESC = CHR(1BH);
BITSPERBYTE = 8;
BITSPERWORD = 16;
PRT = 0;
CON = 2;
TYPE
PrintLine = ARRAY [ 0 .. 10000 ] OF CHAR; (* a BIG buffer *)
VAR
PrintLineBuffer : PrintLine;
PROCEDURE WaitForNoMouse;
VAR dummy : CARDINAL;
stat : BITSET;
BEGIN
REPEAT vq_mouse(VDIHandle, stat,dummy,dummy) UNTIL stat = {};
END WaitForNoMouse;
PROCEDURE CheckPrinterReady() : BOOLEAN;
VAR i : LONGCARD;
BEGIN
i := 100000;
WHILE ( bcostat(PRT) = 0 ) & ( i > 0 ) DO DEC(i) END;
RETURN ( i > 0 );
END CheckPrinterReady;
PROCEDURE GetPrinterReadyMsg () : BOOLEAN; (* ABORT if FALSE *)
VAR f : BOOLEAN;
i : CARDINAL;
BEGIN
REPEAT
i := ShowAlert('Printer Not Ready!!!|CANCEL will ABORT print',2,1);
IF i = 2 THEN WaitForNoMouse; RETURN FALSE END;
UNTIL CheckPrinterReady();
WaitForNoMouse;
RETURN TRUE
END GetPrinterReadyMsg;
PROCEDURE QueryAbort() : BOOLEAN; (* If left button down then prompt *)
CONST leftbutton = 15; (* bit numbering starts on left *)
rightbutton= 14;
VAR i, dummy : CARDINAL;
bstatus : BITSET;
BEGIN
vq_mouse(VDIHandle, bstatus, dummy, dummy);
IF ( leftbutton IN bstatus )
OR ( rightbutton IN bstatus ) THEN
i:= ShowAlert('CONTINUE THE PRINT?|CANCEL will ABORT the print',2,1);
WaitForNoMouse;
END;
RETURN ( i = 2 );
END QueryAbort;
PROCEDURE PrintChar ( ch : CHAR ) : BOOLEAN; (* ABORT if FALSE *)
BEGIN
LOOP
IF CheckPrinterReady() THEN
bconout(PRT,ch);
RETURN TRUE
ELSE
IF NOT GetPrinterReadyMsg() THEN RETURN FALSE END;
END;
END;
END PrintChar;
PROCEDURE PrintString ( VAR s : ARRAY OF CHAR; n : CARDINAL ) : BOOLEAN;
VAR i : CARDINAL;
printed : BOOLEAN;
BEGIN
i := 0;
REPEAT
printed := PrintChar(s[i]);
INC(i);
UNTIL ( i >= n ) OR NOT printed;
RETURN printed;
END PrintString;
PROCEDURE SetPrinterMode( linewidth, modeno : INTEGER ) : BOOLEAN;
VAR printed : BOOLEAN;
s : String;
BEGIN
s[0] := ESC;
s[1] := '*';
s[2] := CHAR(modeno);
s[3] := CHAR(linewidth MOD 256 );
s[4] := CHAR(linewidth DIV 256 );
RETURN PrintString(s,5)
END SetPrinterMode;
PROCEDURE SetHiPrinterMode( linewidth, modeno : INTEGER ) : BOOLEAN;
VAR printed : BOOLEAN;
s : String;
BEGIN
s[0] := ESC;
s[1] := '*';
s[2] := CHAR(modeno);
s[3] := CHAR(linewidth MOD 256 );
s[4] := CHAR(linewidth DIV 256 );
RETURN PrintString(s,5)
END SetHiPrinterMode;
PROCEDURE SetLineFeedDepth( n180ths : INTEGER ) : BOOLEAN;
VAR s : String;
BEGIN
s[0] := ESC; s[1] := '3'; s[2] := CHAR(n180ths);
RETURN PrintString(s,3);
END SetLineFeedDepth;
PROCEDURE PrintCRLF (n : INTEGER) : BOOLEAN;
VAR s : String;
printed : BOOLEAN;
i : INTEGER;
BEGIN
s[0] := CHAR(13);
s[1] := CHAR(10);
i := 1;
WHILE PrintString(s,2) & ( i < n ) DO INC(i) END;
RETURN ( i >= n );
END PrintCRLF;
PROCEDURE PrintBottomMargin ( n : CARDINAL ) : BOOLEAN;
VAR i : CARDINAL;
BEGIN
i := 0;
WHILE PrintChar(' ') & ( i < n ) DO INC(i) END;
RETURN ( i >= n );
END PrintBottomMargin;
PROCEDURE SetFormLength ( n : CARDINAL ) : BOOLEAN;
VAR s : String;
BEGIN
s[0] := ESC; s[1] := 'C'; s[2] := 0C; s[3] := CHAR(n);
RETURN PrintString(s,4);
END SetFormLength;
PROCEDURE ResetPrinter() : BOOLEAN;
VAR s : String;
BEGIN
s[0] := ESC; s[1] := '@';
RETURN PrintString(s,2);
END ResetPrinter;
PROCEDURE FormFeed() : BOOLEAN;
VAR s : String;
BEGIN
s[0] := CHAR(12);
RETURN PrintString(s,1);
END FormFeed;
(*----------------------------------------------------------------------*)
(* Print landscape picture *)
(*----------------------------------------------------------------------*)
PROCEDURE PrintHiResPicture24L ( VAR PictureDetails : PictureImage;
VAR PrintDetails : PrintImage;
VAR Picture : HiResScreen );
VAR nomore, newpic : BOOLEAN;
BEGIN
nomore := FALSE;
newpic := TRUE;
IF NOT ResetPrinter() THEN RETURN END;
IF NOT SetFormLength(11) THEN RETURN END;
IF NOT PrintCRLF(PrintDetails.StartCharY) THEN RETURN END;
IF NOT SetLineFeedDepth(24) THEN RETURN END;
REPEAT
PrtCnv24BitSlice( newpic, (* first time thru = TRUE *)
nomore, (* all slices retrieved *)
Picture, (* screen to print *)
PictureDetails.StartX,
PictureDetails.StartY,
PictureDetails.Width,
PictureDetails.Height,
PrintDetails.Width,
PrintDetails.Height,
PrintDetails.QueryLandscapePrint,
PrintLineBuffer );
newpic := FALSE;
IF NOT PrintBottomMargin(PrintDetails.StartCharX) THEN RETURN END;
IF NOT SetPrinterMode(PrintDetails.Height, 39) THEN RETURN END;
IF NOT PrintString(PrintLineBuffer, PrintDetails.Height * 3) THEN
RETURN
END;
IF NOT SetLineFeedDepth(24) THEN RETURN END;
IF NOT PrintCRLF(1) THEN RETURN END;
IF QueryAbort() THEN RETURN END;
UNTIL nomore;
IF NOT ResetPrinter() THEN RETURN END;
END PrintHiResPicture24L;
(*----------------------------------------------------------------------*)
(* Print portrait picture *)
(*----------------------------------------------------------------------*)
PROCEDURE PrintHiResPicture24P ( VAR PictureDetails : PictureImage;
VAR PrintDetails : PrintImage;
VAR Picture : HiResScreen );
VAR nomore, newpic : BOOLEAN;
BEGIN
nomore := FALSE;
newpic := TRUE;
IF NOT ResetPrinter() THEN RETURN END;
IF NOT SetFormLength(11) THEN RETURN END;
IF NOT PrintCRLF(PrintDetails.StartCharY) THEN RETURN END;
IF NOT SetLineFeedDepth(24) THEN RETURN END;
REPEAT
PrtCnv24BitSlice( newpic, (* first time thru = TRUE *)
nomore, (* all slices retrieved *)
Picture, (* screen to print *)
PictureDetails.StartX,
PictureDetails.StartY,
PictureDetails.Width,
PictureDetails.Height,
PrintDetails.Width,
PrintDetails.Height,
PrintDetails.QueryLandscapePrint,
PrintLineBuffer );
newpic := FALSE;
IF NOT PrintBottomMargin(PrintDetails.StartCharX) THEN RETURN END;
IF NOT SetPrinterMode(PrintDetails.Width, 39) THEN RETURN END;
IF NOT PrintString(PrintLineBuffer, PrintDetails.Width * 3) THEN
RETURN
END;
IF NOT SetLineFeedDepth(24) THEN RETURN END;
IF NOT PrintCRLF(1) THEN RETURN END;
IF QueryAbort() THEN RETURN END;
UNTIL nomore;
IF NOT ResetPrinter() THEN RETURN END;
END PrintHiResPicture24P;
END DCPrnt24.